﻿using System;

namespace FDEE.Model
{
    /// <summary>
    /// 不等U型L=A+B+C-r-2d
    /// </summary>
    public class MUNRebarRecord : RebarBase
    {
        public MUNRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            double aa, double bb, double cc): base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            A = aa;
            B = bb;
            C = cc;          
            r = RebarKnowledge.GerRadius(diameter);
            d = PublicEnumItems.GeteDBData(diameter.ToString());
        
            this.Formula = "L=A+B+C-r-2d";
        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C - r - d * 2) * 0.001, 3, MidpointRounding.AwayFromZero);
        }
    }

    /// <summary>
    /// U型带弯曲的L=A+B+C+D+E-2r-4d
    /// </summary>
    public class MULRebarRecord : RebarBase
    {
        public MULRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
            double aa, double bb, double cc, double dd, double ee) : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg)
        {
            A = aa;
            B = bb;
            C = cc;
            D = dd;
            E = ee;
            r = RebarKnowledge.GerRadius(diameter);
            d = PublicEnumItems.GeteDBData(diameter.ToString());

            this.Formula = "L=A+B+C+D+E-2r-4d";
        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C+D+E - 2*r - d * 4) * 0.001, 3, MidpointRounding.AwayFromZero);
        }
    }

    /// <summary>
    /// U型带直线的L=A+B+C+D-1.5r-3d
    /// </summary>
    public class MUARebarRecord : RebarBase
    {
        public MUARebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter, int quantity, eShapeType shapeConfg,
           double aa, double bb, double cc, double dd,EXNumber ex=null) : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfg,ex)
        {
            A = aa;
            B = bb;
            C = cc;
            D = dd;
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            r = RebarKnowledge.GerRadius(diameter);
            d = PublicEnumItems.GeteDBData(diameter.ToString());

            this.Formula = "L=A+B+C+D-1.5r-3d";
        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C + D  + E  - 1.5 * r - d * 3) * 0.001, 3, MidpointRounding.AwayFromZero);
        }
    }
}
